package com.ming.easyDevelop.service.impl;

import com.ming.easyDevelop.mappers.OrderDetailsMapper;
import com.ming.easyDevelop.entity.po.OrderDetails;
import com.ming.easyDevelop.entity.query.OrderDetailsQuery;
import java.util.List;
import org.springframework.stereotype.Service;
import com.ming.easyDevelop.service.OrderDetailsService;
import com.ming.easyDevelop.entity.vo.PaginationResVo;
import java.math.BigDecimal;
import com.ming.easyDevelop.entity.baseEnum.PageSize;
import com.ming.easyDevelop.entity.query.base.SimplePage;
@Service("orderDetailsService")
public class OrderDetailsServiceImpl implements OrderDetailsService {
	private final OrderDetailsMapper<OrderDetails, OrderDetailsQuery> orderDetailsMapper;

	public OrderDetailsServiceImpl(OrderDetailsMapper orderDetailsMapper){
		this.orderDetailsMapper = orderDetailsMapper;
	}
	/**
	 * 根据条件查询列表
	 */
	@Override
	public List<OrderDetails> findListByParam(OrderDetailsQuery query){
		return this.orderDetailsMapper.selectList(query);
	}

	/**
	 * 根据条件查询数量
	 */
	@Override
	public Long findCountByParam(OrderDetailsQuery query){
		return this.orderDetailsMapper.selectCount(query);
	}

	/**
	 * 根据条件分页查询列表
	 */
	@Override
	public PaginationResVo<OrderDetails> findListByPage(OrderDetailsQuery query){
		Long count = this.findCountByParam(query);
		int pageSize = query.getPageSize() == null ? PageSize.SIZE20.getSize() : query.getPageSize();
		SimplePage simplePage = new SimplePage(query.getPageNo(), pageSize, Math.toIntExact(count));
		List<OrderDetails> res = this.findListByParam(query);
		return new PaginationResVo<OrderDetails>(query.getSimplePage().getPageNo(), query.getSimplePage().getPageSize(), query.getSimplePage().getCountTotal(), query.getSimplePage().getPageTotal(), res);
	}

	/**
	 * 批量新增
	 */
	@Override
	public Long addBatch(List<OrderDetails> list){
		return this.orderDetailsMapper.insertBatch(list);
	}

	/**
	 * 新增
	 */
	@Override
	public Long add(OrderDetails bean){
		return this.orderDetailsMapper.insert(bean);
	}

	/**
	 * 新增
	 */
	@Override
	public Long addOrUpdate(OrderDetails bean){
		return this.orderDetailsMapper.insertOrUpdate(bean);
	}

	/**
	 * 新增
	 */
	@Override
	public Long addOrUpdateBatch(List<OrderDetails> list){
		return this.orderDetailsMapper.insertOrUpdateBatch(list);
	}

	/**
	 * 根据OrderDetailID查询
	 */
	@Override
	public OrderDetails getByOrderDetailID(Integer orderDetailID){
		return this.orderDetailsMapper.selectByOrderDetailID(orderDetailID);
	}

	/**
	 * 根据OrderDetailID更新
	 */
	@Override
	public Long updateByOrderDetailID(OrderDetails bean, Integer orderDetailID){
		return this.orderDetailsMapper.updateByOrderDetailID(bean,orderDetailID);
	}

	/**
	 * 根据OrderDetailID删除
	 */
	@Override
	public Long deleteByOrderDetailID(Integer orderDetailID){
		return this.orderDetailsMapper.deleteByOrderDetailID(orderDetailID);
	}

}
